home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11500 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  36 lines

  1. Newsgroups: comp.lang.c++
  2. Path: newshub.nosc.mil!news!news
  3. From: sampson@cod.nosc.mil (Charles H. Sampson)
  4. Subject: Specifying Data Layout
  5. Message-ID: <1996Mar14.173643.8651@nosc.mil>
  6. Sender: news@nosc.mil
  7. Organization: Computer Sciences Corporation
  8. Date: Thu, 14 Mar 1996 17:36:43 GMT
  9.  
  10.      I've just finished reading the reference manual part of Stroustrup's
  11. "The C++ Programming Language" (2nd ed) and have a number of questions. 
  12. This one is particularly important to a project I'm working on.  A quick
  13. search of the FAQ didn't turn up anything, nor does it seem to appear in
  14. the 1400+ articles currently in the comp.lang.c++ newsgroup on my news
  15. server.
  16.  
  17.      Is there some way of precisely specifying the memory layout of a
  18. struct?  In other words, can you say, "This struct is to occupy 3 words of
  19. memory, element foo is to occupy bits 5-12 of word 1, element fern is to
  20. occupy ..."?  If it can be done with a struct, can it also be done with a
  21. class (specifying locations for the data members only)?  In this case, can
  22. you also control the gizmo that is used to distinguish the various values
  23. of a class hierarchy, both where it is to be allocated and the values to be
  24. used to identify specific members of the hierarchy?
  25.  
  26.      For those who don't understand why anyone would want to do such stuff,
  27. the issue is trying to make a class hierarchy out of data that were defined
  28. and mapped to bits long before OO concepts arose.
  29.  
  30.      For reference, in Ada the technique for specifying the exact bits of a
  31. struct (record) is called a representation specification and the gizmo is
  32. called the class's tag.  (I'm not trying to wave any red flags here; just
  33. attempting to use a precise term where it exists.)
  34.  
  35.                                 Charlie
  36.